package com.cardetective.shopcar.utils

import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import androidx.core.content.ContextCompat.getSystemService

class CommonUtil {

     fun copyStr(context: Context,copyStr: String): Boolean {
        return try {
            // 获取剪贴板管理器
            val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
            // 创建普通字符型ClipData
            val clipData = ClipData.newPlainText("Label", copyStr)
            // 将ClipData内容放到系统剪贴板里
            clipboard.setPrimaryClip(clipData)
            true
        } catch (e: Exception) {
            false
        }
    }

}